package com.whj.apipassenger.controller;

import com.whj.apipassenger.service.OrderService;
import com.whj.internalcommon.dto.ResponseResult;
import com.whj.internalcommon.request.OrderRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther: wanghaijun
 * @Date: 2023/1/28 - 01 - 28 - 14:14 
 * @Description: com.whj.apipassenger.controller
 */


@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 创建订单 // 下单
     * @return
     */
    @PostMapping("/add")
    public ResponseResult add(@RequestBody OrderRequest orderRequest){

        System.out.println(orderRequest);
        return orderService.orderAdd(orderRequest);
    }

    /**
     * 乘客取消订单
     *
     * @param orderId 订单id
     * @return
     */
    @PostMapping("/cancel")
    public ResponseResult cancel(@RequestParam Long orderId){
        return orderService.cancel(orderId);
    }
}
